
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 3
 * @Author : WangRuoyu 
 * @Date : 2023/5/11 15:35
 */

#include "iostream"
#include "cstring"
#include "algorithm"

using namespace std;

int months[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int isLaep(int year) {
    if (year % 4 == 0 && year % 100 || year % 400 == 0) {
        return 1;
    }
    return 0;
}

int getDays(int year, int month) {
    if (month == 2) return months[month] + isLaep(year);
    return months[month];
}

int main() {
    int a, b, c, y1, y2;

    cin >> a >> b >> c >> y1 >> y2;

    int days = 0;

    for (int i = 1850; i <= y2; ++i) {
        for (int j = 1; j <= 12; ++j) {
            if (i >= y1 && j == a) {
                int w = (1 + days) % 7;
                int cnt = 0;
                for (int k = 1; k <= getDays(i, j); ++k) {
                    if (w == c - 1) {
                        cnt++;
                        if (cnt == b) {
                            printf("%04d/%02d/%02d\n", i, j, k);
                            break;
                        }
                    }
                    w = (w + 1) % 7;
                }
                if (cnt < b) cout << "none" << endl;
            }
            days += getDays(i, j);
        }
    }
    return 0;
}